﻿@model IEnumerable<ServerManager.Models.IpAddressViewModel>

@{
    ViewData["Title"] = "Index";
}

<div style="height:40px;line-height:40px;margin-top:10px;">
    <div style="float:left;font-size:2em;">Ip地址列表</div>
    <div style="float:right"><a class="btn btn-info" asp-action="CreateOrUpdate">新建</a></div>
</div>
<hr />
<table class="table">
    <thead>
        <tr>
            <th></th>
            <th>
                @Html.DisplayNameFor(model => model.Ip)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ServerId)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Status)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Remark)
            </th>
            <th class="col-lg-1"></th>
        </tr>
    </thead>
    <tbody>
        @{ int i = 1; }
        @foreach (var item in Model)
        {
            string c = string.Empty;
            string status = string.Empty;
            if (item.Status == 0)
            {
                c = "NotAvailable";
                status = "不可用";
            }
            else if (item.Status == 1)
            {
                c = "Idle";
                status = "空闲";
            }
            else if (item.Status == 2)
            {
                c = "Used";
                status = "占用";
            }
        <tr class=@c>
            <td>@(i++)</td>
            <td>
                @Html.DisplayFor(modelItem => item.Ip)
            </td>
            <td>
                <a asp-controller="Server" asp-action="Details" asp-route-id="@item.ServerId">
                    @Html.DisplayFor(modelItem => item.ServerPosition)
                </a>
            </td>
            <td>
                @status
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Remark)
            </td>
            <td>
                <a class="btn btn-info" asp-action="CreateOrUpdate" asp-route-id="@item.Id">编辑</a>
            </td>
        </tr>
        }
    </tbody>
</table>
